package business.command.product
{
	import business.event.product.AddCategoryToDatabaseEvent;
	import business.service.delegate.ProductAMDelegate;
	
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import mx.rpc.IResponder;
	import mx.controls.Alert;
	import valueObjects.Category;
	
	public class AddCategoryToDatabaseCommand implements ICommand, IResponder
	{
		public function AddCategoryToDatabaseCommand()
		{
		}
		public function execute(event:CairngormEvent):void {
			addedCategory = (event as AddCategoryToDatabaseEvent).category;
			var productAM:ProductAMDelegate = new ProductAMDelegate(this);
			productAM.addCategoryToDatabase(addedCategory);
		}
		public function result(result:Object):void {
			var returnResult:Boolean = false;
			returnResult = result.result as Boolean;
			if(returnResult){
				Alert.show("add category to database successfully"); 
			}
		}
		public function fault(info:Object):void {
			
		}
		private var addedCategory:Category;

	}
}